package main

import (
	"fmt"
	"time"
)

func main() {
	ch:=make(chan int)
	flag:=make(chan bool)

	go func() {
		for {
			select {
				case n:=<-ch:
					fmt.Println(n)
				case <-time.After(time.Second*3):
					flag<-true
					goto lable
			}
		}
		lable:
			fmt.Println("结束")
	}()

	for i:=0;i<5 ; i++ {
		ch<-i
	}
	<-flag
}
